package com.simp.app.presenter.impl;

import com.simp.app.model.LoginInteractor;
import com.simp.app.model.OnLoginFinishedListener;
import com.simp.app.model.impl.LoginInteractorImpl;
import com.simp.app.presenter.LoginPresenter;
import com.simp.app.view.LoginView;

/**
 * 
 * Created by hanWG on 2015-10-21 下午5:20:42 $
 * 
 * @Description 登录逻辑处理
 *              <p/>
 */
public class LoginPresenterImpl implements LoginPresenter,
		OnLoginFinishedListener {
	private LoginView loginView;
	private LoginInteractor loginInteractor;
	public LoginPresenterImpl(LoginView loginView) {
		this.loginView = loginView;
		this.loginInteractor = new LoginInteractorImpl();
	}
	@Override
	public void validateCredentials(String username, String password) {
		loginView.showProgress();
		loginInteractor.login(username, password, this);
	}
	@Override
	public void onUsernameError() {
		loginView.setUsernameError();
		loginView.hideProgress();
	}
	@Override
	public void onPasswordError() {
		loginView.setPasswordError();
		loginView.hideProgress();
	}
	@Override
	public void onSuccess() {
		loginView.navigateToHome();
	}
}
